home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / specdisk.arc / !LANMAG.TXT < prev    next >
Text File  |  1991-10-30  |  12KB  |  297 lines

  1.  
  2. {We at Artisoft are excited about the opportunity to communicate directly
  3. {to our LANtastic users.  We'll be providing you with solutions for some
  4. {common problems, sharing some helpful hints, and encouraging you to try
  5. {more of LANtastics many features.  This column will cover some of the
  6. {batch file programming techniques useful in setting up larger, more
  7. {complicated networks. 
  8.  
  9. [{Network Management}]
  10.  
  11. Many LANtastic networks start simply, designed to allow users to share an
  12. expensive peripheral device or information in a common data base.  As
  13. users become more familiar with the operation and advantages of a
  14. network, more nodes are added, both as servers and workstations, and
  15. managing the network becomes more complicated. 
  16.  
  17. As the network grows, the simple batch files described in the previous
  18. column become more cumbersome.  Each user on the network does not
  19. have the same needs, and certainly does not need access to the same
  20. programs.  Setting up an individual batch file on each machine limits each
  21. user to his assigned computer.  If Bill works in accounting, and Jane
  22. works in production, neither one can work at the other's machine without
  23. reconfiguring the network connections on each machine.  
  24.  
  25. This column will use the LANtastic [NET STRING] command to present a
  26. scheme that allows each computer's network connections to be configured
  27. by user, and not by computer.  The LANtasic Network Operating System
  28. Reference Manual describes the NET STRING command as follows:
  29.  
  30.       This command assigns a STRING of characters to a pre-
  31.       existing environmental variable that is either typed in 
  32.       by the user or extracted from one of LANtastic's special
  33.       Strings. You can use these Strings just like DOS environmental
  34.       Strings.  These are useful for prompting users to enter their
  35.       passwords, user names or any other information. It is
  36.       especially useful in batch files  . . .
  37.  
  38. This short paragraph states the purpose of the command but not the
  39. implications.  The NET String command allows the system administrator
  40. to create batch files that are truly interactive!  The command allows the
  41. administrator to store vital network information in environmental variables
  42. that can be used by other batch files.  The NET STRING command will
  43. work with or without the network running.
  44.  
  45. The syntax is:  NET STRING (/LEFT=n)(/RIGHT=n) variable String1 String2
  46.  
  47. /LEFT                       First character from the left that will be
  48.                         extracted from a String.
  49. /RIGHT                      The last character that will be extracted from
  50.                         a String.
  51. Variable                    Pre-existing environmental variable to receive
  52.                         a String.
  53. STRING1                     STRING to replace environmental variable.
  54. STRING2                     Optional sting to be concatenated with String 1.
  55.  
  56.  
  57. The environmental variable is defined within a batch file with the set
  58. command.  Enough characters must be allocated for the largest entry you
  59. wish to permit.  
  60.  
  61. The syntax to define a variable is:  SET name=xxxxxxxx
  62.  
  63. Name is the name of the variable. The x's allocate the space, in this
  64. example the variable name is allowed to be 8 characters long.
  65.  
  66. When the pre-existing environmental variable is defined in the autoexec.bat
  67. file, then any changes made to the String will remain in effect until the
  68. system is rebooted or the variable is changed with the NET STRING
  69. command.  If the variable is defined in another batch file, the variable is
  70. local to that batch file. The String and its contents are lost when the batch
  71. file ends.
  72.  
  73. The LANtastic special Strings are listed in the beginning of the NET Line
  74. Commands section of the manual.  The special Strings used in this column
  75. are:
  76.  
  77. ?"prompt"            Prompts the user for input, and echoes input to
  78.                   screen.
  79. ^"prompt"            Prompts the user for input, and DOES NOT echo input
  80.                   to screen.
  81. !"ETEXT=n"           Expands the error number n to text.
  82. !"INSTALLED"         Expands to characters corresponding to installed
  83.                   programs. N=NETBIOS, R=REDIR,S=SERVER, L=LANPUP, 
  84.                   -=Not installed.
  85. !"LOGIN=server"      Returns TRUE if already logged into server FALSE
  86.                   if not
  87. !"NODEID"            Expands to 12 digit NETBios Node number.
  88. !"MACHINEID"         Expands to name of machine being used.
  89.  
  90. Lets set up a simple network. We will use the network described in the
  91. previous column.  We have five computers-three ATs and two XTs.  Each
  92. AT has one 40MB hard drive and one printer.  Both XTs have 2 floppy
  93. drives but no hard drives or printers.  Each AT has LANtastic installed as
  94. a server.  We will name the ATs AT1, AT2, and AT3, and call the XTs XT1
  95. and XT2.  AT1 will be the master computer on the network.  This means
  96. that AT1 will always be booted as a server, and will contain the batch files
  97. that administer the network in a directory named NET.MGR.
  98.  
  99. The autoexec.bat file for AT2 and AT3 is listed below the standard DOS
  100. prompt etc. left out for clarity:
  101. PATH=c:\lantasti;c:\dos;c:\bat;c\util
  102.  REM Path including LANtastic directory   
  103. SET answer=xxxxxxxxxxxxxxxxxxxx
  104. SET name=xxxxxxx                        
  105. SET password=xxxxxxxx
  106.  REM Define environmental variables for use            
  107. NET STRING answer ?"Install Lantastic Network (y/N)"
  108.  REM Print STRING in quotes, wait for response, and place response in
  109.  REM variable answer 
  110. IF NOT %answer%==Y GOTO exit
  111.  REM if response anything but Y exit to dos without installing network, NET
  112.  REM STRING converts character to upper case   
  113. LANBIOS2/AUTO
  114.  REM Install netbios                      
  115. REDIR ATn LOGINS=3 BUFFERS=2
  116.  REM Install redirector            
  117. NET STRING answer ?"Install as a LANtastic Server (y/N)"
  118.  REM Print String in quotes, wait for response, and place response in
  119.  REM variable answer 
  120. IF NOT %answer%==Y GOTO login
  121.  REM if response anything but Y, continue without installing server 
  122. SERVER
  123.  REM Load server 
  124. :login
  125. login
  126.  REM  Run login.bat 
  127. :exit
  128.  
  129. The autoexec.bat for AT1 is:
  130.  
  131. PATH=c:\lantasti;c:\dos;c:\bat;c\util
  132. SET answer=xxxxxxxxxxxxxxxx                       
  133. SET name=xxxxxxx                        
  134. SET password=xxxxxxxx     
  135. LANBIOS2/AUTO                             
  136. REDIR AT1 LOGINS=3 BUFFERS=2
  137. SERVER
  138. login
  139.  
  140. The following batch files login.bat and logout.bat are  the same on all
  141. computers on the network.
  142.  
  143. LOGIN.BAT
  144.  
  145. @ECHO OFF
  146. SET NET_ERROR=XXX
  147. :start
  148. NET STRING name ?"Please enter your user name"
  149.  REM prompt for user name  store in variable name 
  150. NET STRING password ^"Please enter your password"
  151.  REM prompt for password store in variable password 
  152. NET STRING/LEFT=3/RIGHT=3 answer !"INSTALLED"
  153.  REM get the third character of string returned by !"INSTALLED" special
  154.  REM string
  155.  REM check to see if server is loaded, you cannot have spaces before /left
  156.  REM of /right 
  157. IF NOT %answer%==S GOTO redir
  158.  REM if server is not installed go to redir and log onto master server
  159. NET STRING answer !"Machineid"
  160.  REM determines the local name of the computer
  161. NET/NOERROR LOGIN \\%answer%  %name% %password%
  162.  REM server logs into itself 
  163. IF %NET_ERROR%==86 GOTO start
  164. REM If login attempt unsuccessful due to invalid user name or password
  165. REM try again
  166. NET USE lpt1 \\ATn\@printer
  167.  REM and attaches to it's own printer 
  168. :REDIR
  169. NET STRING answer !"LOGIN=AT1"
  170.  REM Check to see if already logged into server AT1 
  171. IF %answer%==TRUE GOTO login
  172.  REM  if already logged into server AT1 do not attempt it again
  173. NET LOGIN/WAIT \\AT1 %name% %password%
  174.  REM  login into master server
  175. NET USE z: \\AT1\MANAGER
  176.  REM  attach to shared resource Manager that is the \\AT!\c:\net.mgr
  177. :login
  178. SET tempname=xxxxxxxx
  179. NET STRING tempname %name% i
  180. CALL z:\%tempname%
  181.  REM  run the unique login file for the user, username+I.bat ie johnI.bat
  182. SET password=x
  183.  REM  set the password to x so no one can discover your password
  184.  
  185. Logout.BAT
  186. SET tempname=xxxxxxxx
  187. NET STRING %tempname% %name% o
  188. CALL z:\%tempname%
  189.  REM run the unique batch file to log user off system, username+O.bat ie.
  190.  REM johnO.bat
  191. CALL reset
  192. REM restore current PATH
  193.  
  194. The final pieces of this system are the individual batch files for each user. 
  195. These batch files are named with username with the letter i added to the
  196. end of the login files and the letter o added to the logout files.  These 
  197. files contain the necessary commands to log users onto the server they
  198. needs to use and attach to the shared resources on that server.  Thus
  199. each user will have two batch files in the net.mgr directory of server AT1. 
  200. Each computer may have batch file for network configuration commands
  201. peculiar to the individual computer.
  202.  
  203. Below are sample login and logout batch files:
  204.  
  205. Johni.bat - login batch file for user John
  206.  
  207. NET LOGIN/WAIT \\AT2 %name% %password%
  208. REM attempt to login to server AT2 if server AT2 is not available wait until
  209. REM it comes up or user presses escape key
  210. NET LOGIN/WAIT \\AT3 %name% %password%
  211. NET STRING/LEFT/RIGHT answer !"server=at2"
  212. IF %answer%==- GOTO noat2
  213. REM if login to at2 not successful skip attempt to use resources
  214. NET USE d: \\AT2\c-drive
  215. NET USE LPT2 \\AT2\@printer
  216. :noat2
  217. NET STRING/LEFT/RIGHT answer !"server=at3"
  218. IF %answer%==- GOTO noat3
  219. REM if login to at3 not successful skip attempt to use resources
  220. NET USE e: \\AT3\c-drive
  221. :noat3
  222. NET USE f: \\AT1\wp
  223. NET USE g: \\AT1\123data
  224. PATH>RESET.BAT
  225. REM save copy of current path to file on local drive reset.bat
  226. PATH=%PATH%;f:\;g:\
  227. REM add new directories to path
  228. NET STRING answer !"machineid"
  229. REM get name of node
  230. SET tempname=xxxxxxxxxxxx
  231. NET STRING tempname %answer% .bat
  232. IF EXIST z:\%tempname% call %answer%
  233. REM if a node specific batch file exists run it
  234.  
  235. Johno.bat - logout file for user John
  236.  
  237. NET/NOERROR LOGOUT \\at1
  238. REM suppress error messges with the /NOERROR switch just in case
  239. REM already logged out
  240. NET/NOERROR LOGOUT \\at2
  241. NET/NOERROR LOGOUT \\at3
  242.  
  243. The following is an example of a machine specific login file for AT2 that
  244. has a modem on com2.
  245.  
  246. AT2.BAT
  247.  
  248. NET STRING/LEFT=3/RIGHT=3 answer !"Installed"
  249. REM  is server running
  250. IF %ANSWER%==S NET QUEUE HALT \\at2 com2
  251. REM If computer is a server halt the spooling to com port #2
  252.  
  253. While these files may appear to be complicated, once they are set up, the
  254. job of the system administrator becomes very easy.  When a new node is
  255. added to the network, you only need to copy autoexec.bat, login.bat and
  256. logout.bat to the new computer.  The autoexec.bat will only need to be
  257. edited to set the network name for the computer and to change the
  258. settings on the netbios, if they are not the default settings.  All other files
  259. are stored in the net.mgr directory on the master server. Access
  260. permissions can be set for the net.mgr, so that no one else can edit the
  261. files.
  262.  
  263. The NET STRING command can be used in many other places.  Almost
  264. any batch file can benefit from the NET STRING command.  With a little
  265. ingenuity, an entire menu-driven system can be developed, using only
  266. standard batch commands and NET STRING.  Even if you do not use the
  267. batch files presented in this column, their example should explain the
  268. operation of this very powerful, but seldom used, command.
  269.  
  270.  
  271. I've tried to make this column as beneficial as possible.  Please feel free
  272. to contact us if you have any questions or if there is a subject you would
  273. like us to cover.
  274.  
  275. If you're experiencing a problem, our Technical Support department and
  276. electronic bulletin board service (ARTIFACTS BBS) are available at no
  277. charge.  You may call or write to ARTISOFT at:
  278.  
  279. Artisoft Inc.
  280. Public Relations/Lan Times
  281. 575 E. River Rd.
  282. Tucson, Az.  85704
  283. Tele: (602) 293-6363
  284. FAX:  (602) 293-8065
  285. BBS: (602) 293-0065
  286.  
  287. Note:  These batch files were developed using LANtastic NOS V3.0x. 
  288. Version 3.00 introduced several new features including the NET
  289. LOGIN/WAIT command used in these batch files.  The software upgrade
  290. is available from Artisoft for $50.00.
  291.  
  292. {THIS ARTICLE REPRODUCED HERE WITH THE PERMISSION OF "LAN
  293. MAGAZINE"}
  294.  
  295.  
  296.  
  297.